package com.demo3;

public class GoodsTest {
    public static void main(String[] args) {
        //1.创建一个数组
        Goods[] arr = new Goods[3];
        //2.创建3个商品对象
        Goods goods1 = new Goods("001","华为Mate40",5999.00,100);
        Goods goods2 = new Goods("002","保温杯",227.00,50);
        Goods goods3 = new Goods("003","枸杞",12.7,70);
        //3.把商品添加到数组中
        arr[0]=goods1;
        arr[1]=goods2;
        arr[2]=goods3;
        //4.遍历数组
        for (int i = 0; i < arr.length; i++) {
            //i 索引  arr[i] 元素
            Goods goods = arr[i];
            System.out.println("商品的id为:"+goods.getId()+"\t"+
                    "商品的名称为:"+goods.getName()+"\t"+
                    "商品的价格为"+goods.getPrice()+"\t"+
                    "商品的库存为:"+goods.getCount());
        }
    }
}
